package com.github.yoojia.flow.support;

import com.github.yoojia.flow.Context;
import com.github.yoojia.flow.Event;
import com.github.yoojia.flow.EventHandler;

/**
 * @author 陈小锅 (yoojiachen@gmail.com)
 * @since 1.0.0
 */
public abstract class CheckedEventHandler implements EventHandler {

    @Override
    final public void onHandleEvent(Context context, Event event) {
        if (acceptEvent(event)) {
            onHandleEventImpl(context, event);
        }
    }

    protected abstract boolean acceptEvent(Event event);

    protected abstract void onHandleEventImpl(Context context, Event event);

}
